package cn.edu.swufe.stu2025.rateexample;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBHelper extends SQLiteOpenHelper {
    //创建数据库
    private static final int VRESION=1;
    private static final String DB_NAME="myrate.db";
    public static final String TB_NAME = "tb_rates";
    public DBHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }
    public DBHelper(Context context){
        super(context,DB_NAME,null,VRESION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String createTable = "CREATE TABLE "+ TB_NAME + "(" +
                "ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
                "CURNAME TEXT, " +
                "CURRATE TEXT)";
        db.execSQL(createTable);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //先空一下
    }
}
